<script type="text/javascript" src="/scripts/jquery.min.js"></script>
<script type="text/javascript" src="/scripts/tableRowCheckboxToggle.js"></script>

<? $this->load->library('user_agent'); ?>

<? if($row->subhead == ''){ ?>
	<table border="0" width="100%" cellspacing="0" cellpadding="0" class="main" style="margin-bottom:1.2em">
		<?}else{?>
			<table border="0" width="100%" cellspacing="0" cellpadding="0" class="main">
				<?}?>


				<tr>
					<td width="8%" valign="top">
						<div align="right" style="padding-top:3em">
							<img src="/images/brands/<?=$row->brand?>.gif">
						</div> 
					</td>
					<td width="88%">
						<h1><?=$title?></h1>
						<? if($row->subhead){ ?>
							<h2><?=$row->subhead?></h2>
						<?}?>
						</td>
					</tr>
				</table>

				<? $size_big = getimagesize("./images/store/big/$row->id" . '_1.jpg'); ?>
			<? if($size_big[0] > 500){ ?>
				<?//Макет для удилища ?>


				<div align="center">
					<? $this->load->view('store/image_road'); ?>
				</div>


				<table width="100%" border="0" cellspacing="0" cellpadding="0" class="main" style="margin-top:1.2em">
					<tr>
						<td width="8%" valign="top">

						</td>
						<td width="40%" valign="top">
							<? $this->load->view('store/table'); ?>  
						</td>
						<td width="40%" valign="top">
							<?=unhtmlentities ($row->body)?>
						</td>
						<td width="8%">&nbsp;</td>
					</tr>
				</table>


			<?}else{?>
				<?//Макет для всего остального, кроме удилища?>

				<table width="100%" border="0" cellspacing="0" cellpadding="0" class="main">
					<tr>
						<td width="8%">&nbsp;</td>

						<td width="40%">

							<? $this->load->view('store/image_no_road'); ?> 

						</td>
						<td width="40%" valign="top">
							
						

							<?=unhtmlentities ($row->body)?>
						</td>
						<td width="8%">&nbsp;</td>
					</tr>
				</table>

				<table width="100%" border="0" cellspacing="0" cellpadding="0" class="main" style="margin-top:1.2em">
					<tr>
						<td width="8%">&nbsp;</td>
						<td width="80%" valign="top">
							<div align="left" >
								<? $this->load->view('store/table'); ?>          
							</div>
						</td>
						<td width="8%" valign="top">&nbsp;</td>
					</tr>
				</table>
				<? }?>





			<? 


			$store=$this->uri->segment(6);


			$query = $this->db->query("SELECT tag FROM tags_to_store WHERE store='$store' LIMIT 1");
			$row = $query->row(); 


			$query = $this->db->query("SELECT store FROM tags_to_store WHERE store !='$store' AND tag='$row->tag' ORDER BY store");


			if ($query->num_rows() > 0)
			{
				?>

				<br><br><br><table width="100%" border="0" cellspacing="0" cellpadding="0" class="cap" >
					<tr>
						<td width="8%">&nbsp;</td>
						<td width="88%" style="margin-top:0em; background-image:url(/images/global/gor_b.gif);background-repeat: no-repeat;">
							<div style="margin:0.3em 0 0.4em 0"><h3>Похожие товары</h3></div>
						</td>
					</tr>
					<tr>

						<td width="8%">
							<td style="background-image:url(/images/global/gor_lb.gif);background-repeat: no-repeat;padding-top:1em" width="80%"> 


								<div style="padding-bottom:1em">
								<?

							foreach ($query->result() as $row)
							{

								$row=$row->store;




								//Определяем цену/цены
								$price=$this->Store_model->get_price($row);



								$query=$this->db->query("SELECT * FROM store WHERE id ='$row'");
								$row = $query->row(); 


								$level3=$this->db->query("SELECT id,link, father FROM store WHERE id ='$row->father' LIMIT 1");
								$level3 = $level3->row();


								$level2=$this->db->query("SELECT id,link,father FROM store WHERE id ='$level3->father' LIMIT 1");
								$level2 = $level2->row();

								$level1=$this->db->query("SELECT id,link,father FROM store WHERE id ='$level2->father' LIMIT 1");
								$level1 = $level1->row();


								?>


								<? if($level1->id != 1){?>     

									<? if($row->available != 0 ){ ?>
									
									
									<div class="side">
										<a href="/store/catalog/<?=$level1->link?>/<?=$level2->link?>/<?=$level3->link?>/<?=$row->id?>/">
									        <div style="background: url(http://rybalka.com.ua/images/store/preview/<?=$row->id?>_1.jpg) no-repeat; height:200px;width:200px ">
									        <? if($row->action == '1'){ ?>
									        <img src="/images/global/act.png">
									        <?}?>
									        </div>
									       </a>                     
									      <div>
									        <? if($row->brand == 'RM'){ echo "«Рыболовный мир»";}else{ echo $row->brand;}?> <a href="/store/catalog/<?=$level1->link?>/<?=$level2->link?>/<?=$level3->link?>/<?=$row->id?>/"><nobr><?=$row->name?></nobr></a>
									     </div>
									      
									      <div>
									          <small><?=$row->subhead?></small>
									       </div>
									      
									      <div>
									         <? if($price !=0){echo "<b>$price грн</b>";}else{echo "<span class='gray'>Поставка ожидается</span>";} ?>                                  
									      </div>
									</div>
									
									
									
								
												<?}?>

												<?}else{?>
													<? if($row->available == 1){ ?> 
														
														
														
														
														<div>
														   <a href="/store/catalog/<?=$level1->link?>/<?=$level2->link?>/<?=$level3->link?>/<?=$row->id?>/">
														      <div style="background: url(http://rybalka.com.ua/images/store/preview/<?=$row->id?>_1.jpg) no-repeat bottom; height:120px;width:950px ">
														   <? if($row->action == '1'){ ?>
														   <img src="/images/global/act.png">
														   <?}?>
														    </div></a>
														</div>
														
														    <div>
														        <small><?=$row->brand?> <a href="/store/catalog/<?=$level1->link?>/<?=$level2->link?>/<?=$level3->link?>/<?=$row->id?>/"><?=$row->name?></a></small>
														     </div>
														     
														     <div>
														         <small><?=$row->subhead?></small>
														      </div>
														    
														                  
														    <div style="margin-bottom:2em"><small>
														    <?if($price !=0)
														    
														        {echo "<b>$price грн</b>";}
														     else
														        {echo "<font color=\"gray\">Поставка ожидается</font>";}
														        
														    ?></small></div>
														
														
														
															<?}?>
															<?}?>  




															<?}?>

														</div>

													</td>
												</tr>
											</table>     

										</td>

									</tr>
								</table>

								<?}?>


